package com.sg.business.model.dataset.projecttemplate;

import com.mobnut.db.model.IContext;
import com.mongodb.BasicDBObject;
import com.sg.business.model.DocumentTemplate;
import com.sg.business.model.IModelConstants;
import com.sg.business.model.Organization;
import com.sg.business.model.User;
import com.sg.business.model.toolkit.UserToolkit;
import com.sg.widgets.commons.dataset.ContextSingleDataSetFactory;

public class DocTemplateBySelectorOfOrg extends ContextSingleDataSetFactory {

	public DocTemplateBySelectorOfOrg() {
		super(IModelConstants.DB, IModelConstants.C_DOCUMENT_TEMPLATE);
		IContext context = getContext();
		String consignerId = context.getAccountInfo().getConsignerId();
		User user = UserToolkit.getUserById(consignerId);
		Organization org = user.getFunctionOrganization();
		setQueryCondition(new BasicDBObject().append(
				DocumentTemplate.F_ORGANIZATION_ID, org.get_id()));
	}

}
